#!/usr/bin/env python


from PyQt5.QtCore import QDateTime, Qt, QTimer
from PyQt5.QtWidgets import (QApplication, QCheckBox, QComboBox, QDateTimeEdit,
        QDial, QDialog, QGridLayout, QGroupBox, QHBoxLayout, QLabel, QLineEdit,
        QProgressBar, QPushButton, QRadioButton, QScrollBar, QSizePolicy,
        QSlider, QSpinBox, QStyleFactory, QTableWidget, QTabWidget, QTextEdit,
        QVBoxLayout, QWidget)




app = QApplication([])
app.setStyle("Fusion")
window = QWidget()
mainLayout = QGridLayout()

# top
styleComboBox = QComboBox()
styleComboBox.addItems(QStyleFactory.keys())
styleLabel = QLabel("&Style:")
styleLabel.setBuddy(styleComboBox)
useStylePaletteCheckBox = QCheckBox("&Use style's standard palette")
useStylePaletteCheckBox.setChecked(True)
disableWidgetsCheckBox = QCheckBox("&Disable widgets")

topLayout = QHBoxLayout()
topLayout.addWidget(styleLabel)
topLayout.addWidget(styleComboBox)
topLayout.addStretch(1)
topLayout.addWidget(useStylePaletteCheckBox)
topLayout.addWidget(disableWidgetsCheckBox)

# Group 1
topLeftGroupBox = QGroupBox("Group 1")
radioButton1 = QRadioButton("Radio button 1")
radioButton2 = QRadioButton("Radio button 2")
radioButton3 = QRadioButton("Radio button 3")
radioButton1.setChecked(True)

checkBox = QCheckBox("Tri-state check box")
checkBox.setTristate(True)
checkBox.setCheckState(Qt.PartiallyChecked)

layout = QVBoxLayout()
layout.addWidget(radioButton1)
layout.addWidget(radioButton2)
layout.addWidget(radioButton3)
layout.addWidget(checkBox)
layout.addStretch(1)
topLeftGroupBox.setLayout(layout)   

# Group 2
topRightGroupBox = QGroupBox("Group 2")

defaultPushButton = QPushButton("Default Push Button")
defaultPushButton.setDefault(True)

togglePushButton = QPushButton("Toggle Push Button")
togglePushButton.setCheckable(True)
togglePushButton.setChecked(True)

flatPushButton = QPushButton("Flat Push Button")
flatPushButton.setFlat(True)

layout = QVBoxLayout()
layout.addWidget(defaultPushButton)
layout.addWidget(togglePushButton)
layout.addWidget(flatPushButton)
layout.addStretch(1)
topRightGroupBox.setLayout(layout)

# Group 3
bottomLeftTabWidget = QTabWidget()
bottomLeftTabWidget.setSizePolicy(QSizePolicy.Preferred,
        QSizePolicy.Ignored)

tab1 = QWidget()
tableWidget = QTableWidget(10, 10)

tab1hbox = QHBoxLayout()
tab1hbox.setContentsMargins(5, 5, 5, 5)
tab1hbox.addWidget(tableWidget)
tab1.setLayout(tab1hbox)

tab2 = QWidget()
textEdit = QTextEdit()

textEdit.setPlainText("Twinkle, twinkle, little star,\n"
                      "How I wonder what you are.\n" 
                      "Up above the world so high,\n"
                      "Like a diamond in the sky.\n"
                      "Twinkle, twinkle, little star,\n" 
                      "How I wonder what you are!\n")

tab2hbox = QHBoxLayout()
tab2hbox.setContentsMargins(5, 5, 5, 5)
tab2hbox.addWidget(textEdit)
tab2.setLayout(tab2hbox)

bottomLeftTabWidget.addTab(tab1, "&Table")
bottomLeftTabWidget.addTab(tab2, "Text &Edit")

# Group 4
bottomRightGroupBox = QGroupBox("Group 3")
bottomRightGroupBox.setCheckable(True)
bottomRightGroupBox.setChecked(True)

lineEdit = QLineEdit('s3cRe7')
lineEdit.setEchoMode(QLineEdit.Password)

spinBox = QSpinBox(bottomRightGroupBox)
spinBox.setValue(50)

dateTimeEdit = QDateTimeEdit(bottomRightGroupBox)
dateTimeEdit.setDateTime(QDateTime.currentDateTime())

slider = QSlider(Qt.Horizontal, bottomRightGroupBox)
slider.setValue(40)

scrollBar = QScrollBar(Qt.Horizontal, bottomRightGroupBox)
scrollBar.setValue(60)

dial = QDial(bottomRightGroupBox)
dial.setValue(30)
dial.setNotchesVisible(True)

layout = QGridLayout()
layout.addWidget(lineEdit, 0, 0, 1, 2)
layout.addWidget(spinBox, 1, 0, 1, 2)
layout.addWidget(dateTimeEdit, 2, 0, 1, 2)
layout.addWidget(slider, 3, 0)
layout.addWidget(scrollBar, 4, 0)
layout.addWidget(dial, 3, 1, 2, 1)
layout.setRowStretch(5, 1)
bottomRightGroupBox.setLayout(layout)

# process
progressBar = QProgressBar()
progressBar.setRange(0, 10000)
progressBar.setValue(0)

mainLayout.addLayout(topLayout, 0, 0, 1, 2)
mainLayout.addWidget(topLeftGroupBox, 1, 0)
mainLayout.addWidget(topRightGroupBox, 1, 1)
mainLayout.addWidget(bottomLeftTabWidget, 2, 0)
mainLayout.addWidget(bottomRightGroupBox, 2, 1)
mainLayout.addWidget(progressBar, 3, 0, 1, 2)

mainLayout.setRowStretch(1, 1)
mainLayout.setRowStretch(2, 1)
mainLayout.setColumnStretch(0, 1)
mainLayout.setColumnStretch(1, 1)

        
window.setLayout(mainLayout)
window.show()
app.exec_()


